<h2><?=tr('Games administration')?></h2>
<p class="backpage">&raquo; <?=fgsBase::linkPage(tr('Add a game'), 'admin_games', array('add'))?></p>
<?php

	if (!is_null($form)) {

		echo $form->output();
		
	} else {

		$games = fgsGames::get();

		if (!$games)
			echo tr('No games yet');
		else {
			$tbl = new htmlTable();

			$tbl->setHeader('action', array(
				'width' => '50px',
			));
			$tbl->setHeader('id', array(
				'title' => tr('Id'),
				'width' => '5ex',
			));
			$tbl->setHeader('gid', array(
				'title' => tr('Gid'),
				'width' => '10ex',
			));
			$tbl->setHeader('icon', array(
				'title' => tr('Icon'),
				'width' => '18px',
			));
			$tbl->setHeader('name', array(
				'title' => tr('Name'),
			));
			$tbl->setHeader('website', array(
				'title' => tr('Website'),
			));

			foreach ($games as $n) {
				$tbl->set('id', $n['id']);
				$tbl->set('gid', $n['gid']);
				$tbl->set('name', $n['name']);
				if ($n['logo_hash'] != '') 
					$tbl->set('icon', sprintf('<img src="%s" alt="%s"/>', fgsBase::link('game', array($n['gid'], 'logo', 'icon16')), $n['name']));
				$tbl->set('website', sprintf('<a href="%s">%s</a>', $n['url'], $n['url']));

				$actions = array();
				if (!$n['is_disabled']) {
					$actions[] = fgsBase::linkPage(fgsBase::image('del'), 'admin_games', array('hide', $n['id']));
				} else {
					$tbl->setLineParam('class', 'disabled');
					$actions[] = fgsBase::linkPage(fgsBase::image('ok'), 'admin_games', array('show', $n['id']));
				}
				$actions[] = fgsBase::linkPage(fgsBase::image('edit'), 'admin_games', array('edit', $n['id']));

				$tbl->set('action', implode(' ', $actions));
					
				$tbl->push();
			}

			echo $tbl->render();
		}	

	}
	
?>
